#pragma once

#include <string>

using std::string;

struct NFARule
{

    NFARule(char start, char sym, char fin) 
        : from(start)
        , on(sym) 
        , to(fin)
    {
    }
   
    NFARule(const NFARule& t)
        : from(t.from)
        , on(t.on)
        , to(t.to)
    {
    }
    
    NFARule& operator=(const NFARule& t)
    {
        NFARule tmp(t);
        swap(tmp);            
        return *this;
    }        

    string toString()
    {
        string str;
        str += from;
        str += " : ";
        if (on)
            str += on;
        if (to)
            str += to; 
        return str;
    }     

    char from; 
    char on;
    char to;

private:
    void swap(NFARule&);
};

void NFARule::swap(NFARule& t)
{
    char tmp;

    tmp = t.from;
    t.from = from;
    from = tmp;

    tmp = t.on;
    t.on = on;
    on = tmp;
        
    tmp = t.to;
    t.to = to;
    to = tmp;    
}
